package com.example.demo.commen;

import lombok.Data;

@Data
public class Result<T> {

    private int code;  //200代表成功，-1代表失败
    private String errorMsg;
    private T data;

    public static <T>Result success(T data){
         Result<T> result = new Result<>();
         result.setCode(Constant.RESULT_SUCCESS);
         result.setErrorMsg("");
         result.setData(data);
         return result;
    }

    public static Result failed(String ErrorMsg){
        Result result = new Result<>();
        result.setCode(Constant.RESULT_FAILED);
        result.setErrorMsg(ErrorMsg);
        result.setData("");
        return result;
    }
}
